package com.hmsm.sys.action;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.xwork.StringUtils;
import org.springframework.web.servlet.ModelAndView;

import com.hmsm.server.base.BaseAction;
import com.hmsm.server.common.CommonUtil;
import com.hmsm.server.util.KeyValue;
import com.hmsm.server.util.MD5;
import com.hmsm.server.util.QueryResult;
import com.hmsm.server.util.Util;
import com.hmsm.sys.controller.UserInfoController;
import com.hmsm.sys.po.DeptInfo;
import com.hmsm.sys.po.OrgInfo;
import com.hmsm.sys.po.UserInfo;
import com.hmsm.sys.service.DeptInfoService;
import com.hmsm.sys.service.UserOrgService;
import com.lzyyj.common.Page;
import com.opensymphony.xwork2.ActionContext;

public class UserInfoAction extends BaseAction<UserInfo> {

	private static final long serialVersionUID = -5428167759695049911L;
	
	@Resource
	private UserInfoController userInfoController;
	
	public UserInfoController getUserInfoController() {
		return userInfoController;
	}

	@Resource
	private DeptInfoService deptInfoService;
	
	public DeptInfoService getDeptInfoService() {
		return deptInfoService;
	}

	public void setDeptInfoService(DeptInfoService deptInfoService) {
		this.deptInfoService = deptInfoService;
	}
	
	private UserOrgService userOrgService;

	public UserOrgService getUserOrgService() {
		return userOrgService;
	}

	public void setUserOrgService(UserOrgService userOrgService) {
		this.userOrgService = userOrgService;
	}

	private Page<UserInfo> userPage;
	private String nowpage = null;// 页码
	private String maxpage = null;// 每页显示条数	
	private int count;
	private int allPages;
	private int page;//当前页
	private int rowsPage;//每页数量
	private QueryResult<UserInfo> result;
	private Date beginTime;
	private Date endTime;
	private String name;//用户姓名
	private String userName;//用户账号
	private String password;
	private String telphone;
	private String email;
	private String address;
	private int userType;
	private int state;
	private List<UserInfo> userInfoList;
	private String oldPassword;
	private String company;
	private String message;
	private List<KeyValue> infoAll;
	private String parAction;
	private String id;
	private String par;
	private UserInfo user;// 用户信息
	private DeptInfo orgRootDept;
	
	public DeptInfo getOrgRootDept() {
		return orgRootDept;
	}

	public void setOrgRootDept(DeptInfo orgRootDept) {
		this.orgRootDept = orgRootDept;
	}

	private DeptInfo deptInfo;
	private int userId;
    private int pkId;
    private int sn;
	
	private List<DeptInfo> managedOrgList;
	
	public List<DeptInfo> getManagedOrgList() {
		return managedOrgList;
	}

	public void setManagedOrgList(List<DeptInfo> managedOrgList) {
		this.managedOrgList = managedOrgList;
	}

	private List<DeptInfo> departSelectList;
	
	public List<DeptInfo> getDepartSelectList() {
		return departSelectList;
	}

	public void setDepartSelectList(List<DeptInfo> departSelectList) {
		this.departSelectList = departSelectList;
	}

	public int getLoginType() {
		return CommonUtil.loginType;
	}

	public int getPkId() {
		return pkId;
	}

	public void setPkId(int pkId) {
		this.pkId = pkId;
	}

	public int getSn() {
		return sn;
	}

	public void setSn(int sn) {
		this.sn = sn;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getAllPages() {
		return allPages;
	}

	public void setAllPages(int allPages) {
		this.allPages = allPages;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public Date getBeginTime() {
		return beginTime;
	}

	public void setBeginTime(Date beginTime) {
		this.beginTime = beginTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getNowpage() {
		return nowpage;
	}

	public void setNowpage(String nowpage) {
		this.nowpage = nowpage;
	}

	public String getMaxpage() {
		return maxpage;
	}

	public void setMaxpage(String maxpage) {
		this.maxpage = maxpage;
	}

	public QueryResult<UserInfo> getResult() {
		return result;
	}

	public void setResult(QueryResult<UserInfo> result) {
		this.result = result;
	}


	public int getRowsPage() {
		return rowsPage;
	}

	public void setRowsPage(int rowsPage) {
		this.rowsPage = rowsPage;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		if(!"请输入查询内容".equals(name)){
			this.name = name.trim();
		}
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		if(!"请输入查询内容".equals(userName)){
			this.userName = userName.trim();
		}
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getTelphone() {
		return telphone;
	}

	public void setTelphone(String telphone) {
		this.telphone = telphone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getUserType() {
		return userType;
	}

	public void setUserType(int userType) {
		this.userType = userType;
	}

	public int getState() {
		return state;
	}

	public void setState(int state) {
		this.state = state;
	}

	public List<UserInfo> getUserInfoList() {
		return userInfoList;
	}

	public void setUserInfoList(List<UserInfo> userInfoList) {
		this.userInfoList = userInfoList;
	}

	public Integer getRange() {
		Integer range = (Integer) userPage.getCondition().get("range");

		return range;
	}

	public void setRange(Integer range) {
		userPage.getCondition().put("range", range);
	}

	public DeptInfo getDeptInfo() {
		return deptInfo;
	}

	public void setDeptInfo(DeptInfo deptInfo) {
		this.deptInfo = deptInfo;
	}

	public Integer getDeptId() {
		Integer deptId = null;
		if (deptInfo!=null){
			deptId = deptInfo.getPkId();
		}
		return deptId;
	}

	public void setDeptId(Integer deptId) {
		if (deptInfo==null)
		{
			deptInfo = new DeptInfo();
		}
		deptInfo.setPkId(deptId);
	}

	public UserInfo getUser() {
		return user;
	}

	public void setUser(UserInfo user) {
		this.user = user;
	}

	public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}

	public String getCompany() {
		return company;
	}

	public void setCompany(String company) {
		this.company = company;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public List<KeyValue> getInfoAll() {
		return infoAll;
	}

	public void setInfoAll(List<KeyValue> infoAll) {
		this.infoAll = infoAll;
	}

	public String getParAction() {
		return parAction;
	}

	public void setParAction(String parAction) {
		this.parAction = parAction;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getPar() {
		return par;
	}

	public void setPar(String par) {
		this.par = par;
	}
	
	public void setUserDeptIds(String deptIdString){
		List<DeptInfo> userDepts = new ArrayList<DeptInfo>();
		
		if (deptIdString!=null){
			String[] deptIdList = deptIdString.split(",");
			for(String idString:deptIdList){
				if(idString.length()>0){
					Integer deptId = Integer.parseInt(idString);
					DeptInfo deptInfo = new DeptInfo();
					deptInfo.setPkId(deptId);
					userDepts.add(deptInfo);
				}
			}
			if (user == null){
				user = new UserInfo();
			}
		}
		
		user.setUserDepts(userDepts);
	}
	
	public void setUserRoleIds(String roleIdString){
		List<Integer> roleIds = new ArrayList<Integer>();
		
		if (roleIdString!=null){
			String[] roleIdList = roleIdString.split(",");
			for(String idString:roleIdList){
				if(idString.length()>0){
					roleIds.add(Integer.parseInt(idString));
				}
			}
			if (user == null){
				user = new UserInfo();
			}
		}
		
		user.setRoleIds(roleIds);
	}
	
	public List<Map<String, Object>> getRangeTypes(){
		List<Map<String, Object>> rangeTypes = (List<Map<String, Object>>) userPage.getCondition().get("rangeTypes"); 
		return rangeTypes;
	}
	
	public UserInfoAction(){
		userPage = new Page<UserInfo>(10);
		userPage.setFindByExample(new UserInfo());
	}

	/**
	 * 
	 *  @描述:分页获取用户信息
	 *  @方法名称 :getUserInfoAll
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:39:49 
	 *  @return
	 *
	 */
	public String manage() {
		UserInfo currentUser = getSessionUser();
		if (currentUser == null ) {
			this.setMessage("当前用户已失效，请重新登录！");
			return ERROR;
		}
		
		if (page==0) {
			page = 1;// 当前页数
		}
		if (rowsPage==0) {
			rowsPage = 10;// 每页显示数
		}
		if (nowpage != null && !nowpage.trim().equals("")) {
			page = Integer.parseInt(nowpage.trim());
			if (page == 0) {
				page = 1;
			}
		}
		if (maxpage != null && !maxpage.trim().equals("")) {
			rowsPage = Integer.parseInt(maxpage.trim());
		}

		userPage.setPageSize(rowsPage);
		userPage.setPageNo(page);
		userPage.setFindByExample(new UserInfo());
		
		UserInfo example = userPage.getFindByExample();
		example.setDeptId(getDeptId());
		example.setUserName(userName);
		example.setName(name);
		
		try {
			// 如果是管理员，检查一下是否有同名账户
			userPage.getCondition().put("mapResult", mapResult);
			userPage = getUserInfoService().manage(userPage, currentUser);
			mapResult = (Map<String, Object>) userPage.getCondition().get("mapResult");

			result = new QueryResult<UserInfo>();
			result.setResultlist(userPage.getData());
			result.setAllPages(userPage.getTotalPageCount());
			result.setNowPageNumber((int) userPage.getPageNo());
			result.setNowViewRecordNumber((int) userPage.getStartIndex());
			result.setPerPageNumber((int) userPage.getPageSize());
			result.setTotalrecord(userPage.getTotalCount());

			count = (int)userPage.getTotalCount();
			allPages = (int) userPage.getTotalPageCount();//获得总页数
			deptInfo = (DeptInfo) userPage.getFindByExample().getDepart();
			managedOrgList = (List<DeptInfo>) userPage.getCondition().get("managedOrgList");
			
		} catch (Exception e) {
			e.printStackTrace();
			addActionError("发生错误："+e.getMessage());
			return ERROR;
		}
		return SUCCESS;
	}

	/**
	 * 
	 *  @描述:用户信息新增初始化
	 *  @方法名称 :add 	原名 initAddUserInfo
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:39:28 
	 *  @return
	 *
	 */
	public String add() {
		UserInfo currentUser = getSessionUser();
		try {
			user = getUserInfoService().getNew();
			user.setUserDepts(new ArrayList<DeptInfo>());
			user.getUserDepts().add(deptInfo);
			getUserInfoService().loadUserRoles(user, currentUser);
			loadParamList(user);
		} catch (Exception e) {
			message = "发生错误+"+e;
			addActionError(message);
			return ERROR;
		}
		if (user==null){
			message = "要编辑的用户不存在！";
			this.addActionError(message);
			return ERROR;
		}else{
			copyProperties(user);
		}
		definedResult = "edit";
		return "definedResult";
	}

	/**
	 * 
	 *  @描述:用户信息编辑
	 *  @方法名称 :edit
	 *  @作者     :yyj
	 *  @创建日期 :2016-8-21 下午4:39:28 
	 *  @return
	 *
	 */
	public String edit() {
		UserInfo currentUser = getSessionUser();
		HttpServletRequest request = getRequest();
		Integer deptId = null;
		if(deptInfo!=null) {
			deptId = deptInfo.getPkId();
		}
		ModelAndView modelAndView = getUserInfoController().edit(pkId, deptId, currentUser, request);
		if("success".equals(modelAndView.getViewName())){
			deptInfo = (DeptInfo) modelAndView.getModel().get("deptInfo");
			user = (UserInfo) modelAndView.getModel().get("user");
			copyProperties(user);
			managedOrgList = (List<DeptInfo>) modelAndView.getModel().get("managedOrgList");
			departSelectList = (List<DeptInfo>) modelAndView.getModel().get("departSelectList");
		}else{
			message = (String) modelAndView.getModel().get("errorMessage");
			addActionError(message);
			return ERROR;
		}
		return SUCCESS;
	}
	
	public String getDeptSelectList(){
		if (user!=null&&user.getOrg()!=null&&user.getOrg().getPkId()!=null){
			Integer orgId = user.getOrg().getPkId();
			try {
				departSelectList = getDeptInfoService().getDeptSelectList(orgId);
				mapResult.put("success", true);
				mapResult.put("result", departSelectList);
			} catch (Exception e) {
				e.printStackTrace();
				mapResult.put("success", false);
				mapResult.put("errorMessage", e);
			}
		}else{
			departSelectList = new ArrayList<DeptInfo>();
			mapResult.put("success", true);
			mapResult.put("result", departSelectList);
		}
		return "json";
	}

	private void loadParamList(UserInfo userInfo) throws Exception {
		managedOrgList = getDeptInfoService().getManagedOrgSelectList(getSessionUser());
		departSelectList = getDeptInfoService().getDeptSelectList(userInfo.getOrg()==null?null:userInfo.getOrg().getPkId());
	}

	/**
	 * 
	 *  @描述:更新用户信息
	 *  @方法名称 :save 原名 update
	 *  @作者     :yyj
	 *  @创建日期 :2016-8-21 下午4:39:28 
	 *  @return
	 *
	 */
	public String save() {
		if (user == null){
			user = new UserInfo();
		}
		user.setPkId(pkId);
		copyProperties(new Util(), user, "userName,name,userDepts,passWord,telPhone,email,address,roles");
		try {
			UserInfo userInfoPo = getUserInfoService().save(user, "userName,name,userDepts,passWord,telPhone,email,address,roles", getSessionUser());
			this.addActionMessage("角色设置已保存！");
			mapResult.put("success", true);
			mapResult.put("message", "保存成功！");
		} catch (Exception e1) {
			e1.printStackTrace();
			message = "发生错误："+e1;
			mapResult.put("success", false);
			mapResult.put("errorMessage", message);
		}
		return "json";
	}

	/**
	 * 
	 *  @描述:判断用户账号是否已经存在
	 *  @方法名称 :checkUserCode
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:39:00 
	 *
	 */
	public void checkUserCode() {
		UserInfo user;
		try {
			user = getUserInfoService().getUserInfoByUserCode(pkId, userName);
			if (user != null) {
				this.setMessage("用户账号已经存在，请重新填写用户账号信息！");
				this.log(this, "用户（" + userName + "）已经存在！");
				this.writeResponse("2");
			} else {
				this.writeResponse("1");
			}
		} catch (Exception e) {
			e.printStackTrace();
			message = "唯一性验证失败："+ e;
			this.log(this, message);
			this.writeResponse("2");
		}
		// 判断此用户账号是否已经存在
	}

	/**
	 * 
	 *  @描述:新增用户信息
	 *  @方法名称 :addUserInfo
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:38:38 
	 *  @return
	 *
	 */
	public String addUserInfo() {
		Util u = new Util();
		UserInfo user = new UserInfo();
		int deptId = deptInfo.getPkId();
		deptInfo = (DeptInfo) getDeptInfoService().getById(deptId);
		getDeptInfoService().loadParent(deptInfo);
		String dept = deptInfo.getDeptPathName(0);
		OrgInfo orgInfo = getDeptInfoService().getOrgInfoById(deptInfo.getOrgId());
		if (userName == null) {
			this.setMessage("用户账号不能为空！");
			return ERROR;
		}
		if (name == null) {
			this.setMessage("用户姓名不能为空！");
			return ERROR;
		}
		if (password == null) {
			this.setMessage("用户密码不能为空！");
			return ERROR;
		}
		if (telphone == null) {
			this.setMessage("电话不能为空！");
			return ERROR;
		}
		if (email == null) {
			this.setMessage("邮箱不能为空！");
			return ERROR;
		}
		copyProperties(u, user, dept);
		try {
			user = getUserInfoService().save(user, "userName,name,userDepts,passWord,telPhone,email,address,roles", getSessionUser());
			// 保存用户与机构关联信息
			getUserOrgService().save(user.getPkId(), orgInfo.getPkId(), 1, deptId);
		} catch (Exception e) {
			e.printStackTrace();
			this.addActionError("发生错误："+e);
			return ERROR;
		}

		// 更新用户信息
//		CommonUtil.userFuncMap = getRoleInfoService().initUserFunc();
		return SUCCESS;
	}

	private void copyProperties(Util u, UserInfo user, String dept) {
		user.setName(name);// 设置用户姓名
		user.setUserName(userName);// 设置用户账号
		user.setTelPhone(telphone);// 设置电话
		user.setEmail(email);
		user.setAddress(address);// 设置地址
		user.setIdType(null);// 设置腾讯通ID为0
		user.setDepart(new DeptInfo(getDeptId()));
		if (password!=null&&password.length()>0){
			user.updatePassword(password);// 设置密码
		}
		if (dept!=null&&dept.length()>0){
			user.setUserDept(dept);
		}
		user.setState(1);// 1有效 2无效
		user.setType(0);
		user.setCreateDate(u.dateToTimestamp(null));
		user.setSnCode(0);
	}

	private void copyProperties(UserInfo user) {
		name = user.getName();// 设置用户姓名
		userName = user.getUserName();// 设置用户账号
		telphone = user.getTelPhone();// 设置电话
		email = user.getEmail();
		address = user.getAddress();// 设置地址
	}

	/**
	 * 查看用户信息
	 * @return
	 * @author 舒俊
	 */
	public String view() {
		user = getUserInfoService().getById(userId);
		getUserInfoService().loadUserDepart(user);
		Util util = new Util();
		String[] companys = util.getSplitComplex(user.getUserDept(), ">");
		company = companys[companys.length - 1];
		return SUCCESS;
	}

	/**
	 * 
	 *  @描述:删除用户信息
	 *  @方法名称 :deleteUser
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:40:23 
	 *  @return
	 *
	 */
	public String deleteUser() {
		try {
			getUserInfoService().deleteById(userId);
		} catch (Exception e) {
			e.printStackTrace();
			message = "发生错误："+e;
			addActionError(message);
			return adjustForAjax(ERROR);
		}
		return adjustForAjax(SUCCESS);
	}


	private String adjustForAjax(String resultView) {
		
		HttpServletRequest request = (HttpServletRequest) ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
		if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))){
			// ajax 请求
			if (ERROR.equalsIgnoreCase(resultView)||this.hasActionErrors()){
				mapResult.put("success", false);
				mapResult.put("errorMessage", ""+this.getActionErrors());
			}else{
				mapResult.put("success", true);
			}
			return "json";
		}
		
		return resultView;
	}

	/**
	 * 
	 *  @描述:修改个人信息
	 *  @方法名称 :updateUserInfo
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:38:13 
	 *  @return
	 *
	 */
	public String editSelfInfo() {
		UserInfo currentUser = this.getSessionUser();
		if (currentUser == null) {
			this.setMessage("当前用户已失效，请重新登录！");
			return ERROR;
		}
		if (user==null||user.getName()==null){
			user = getUserInfoService().getById(currentUser.getPkId());
			return INPUT;
		}else{
			try {
				UserInfo userPo = getUserInfoService().update(user, "name,address,email");
				if(!StringUtils.isEmpty(user.getPassWord())&&userPo!=null){
					if (oldPassword!=null&&userPo.validatePassword(MD5.getMD5(oldPassword))) {
						getUserInfoService().updatePassword(user.getPassWord(), currentUser);
					}else{
						message = "原密码不正确！";
						addActionError(message);
						return INPUT;
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
				message = "发生错误："+e;
				addActionError(message);
				return ERROR;
			}
			this.setSessionUser(user);
			this.setMessage("修改成功！");
		}
		return SUCCESS;
	}

	/**
	 * 
	 *  @描述:修改密码
	 *  @方法名称 :updateUserPWD
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:37:58 
	 *  @return
	 *
	 */
	public String updateUserPWD() {
		UserInfo currentUser = this.getSessionUser();
		if (currentUser == null) {
			this.setMessage("当前用户已失效，请重新登录！");
			return ERROR;
		}
		UserInfo tempUser = this.user;
		if (tempUser != null) {
			user = getUserInfoService().getById(tempUser.getPkId());
			if (user != null) {
				if (user.validatePassword(oldPassword)) {
					// 密码匹配
					try {
						getUserInfoService().updatePassword(tempUser.getPassWord(), currentUser);
					} catch (Exception e) {
						e.printStackTrace();
						message = "发生错误："+e;
						addActionError(message);
						return ERROR;
					}
					this.setMessage("修改成功，请牢记您的密码！");
				} else {
					this.setMessage("原密码错误！");
				}
			} else {
				this.setMessage("操作失败！");
			}
		}
		return SUCCESS;
	}
	
	/**
	 * 
	 *  @Description:重置账号密码
	 *  @MethodName :reStoreUserPWD
	 *  @Author     :zhangshuai
	 *  @CreateDate :2013-7-26 下午02:07:39 
	 *  @return
	 *
	 */
	public String reStoreUserPWD() {
		UserInfo currentUser = this.getSessionUser();
		if (currentUser == null) {
			this.setMessage("当前用户已失效，请重新登录！");
			return ERROR;
		}
		try {
			getUserInfoService().resetPassword(userId, currentUser);
			mapResult.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			message = "发生错误："+e;
			addActionError(message);
			mapResult.put("success", false);
			mapResult.put("errorMessage", message);
		}
		return "json";
	}
	/**
	 * 
	 *  @Description:重置账号密码
	 *  @MethodName :reStoreUserPWD
	 *  @Author     :zhangshuai
	 *  @CreateDate :2013-7-26 下午02:07:39 
	 *  @return
	 *
	 */
	public String resetPassword() {
		UserInfo currentUser = this.getSessionUser();
		if (currentUser == null) {
			message = "当前用户已失效，请重新登录！";
			mapResult.put("success", false);
			mapResult.put("errorMessage", message);
		}
		try {
			getUserInfoService().resetPassword(userId, currentUser);
			message = "用户密码已经重置！";
			mapResult.put("success", true);
			mapResult.put("message", message);
		} catch (Exception e) {
			e.printStackTrace();
			message = "用户密码重置失败："+e;
			addActionError(message);
			mapResult.put("success", false);
			mapResult.put("errorMessage", message);
		}
		return "json";
	}
	
	/**
	 * 
	 *  @Description:绑定用户密令卡
	 *  @MethodName :bindingUserMLInfo
	 *  @Author     :yaosq
	 *  @CreateDate :2013-11-15 下午05:18:12 
	 *  @param pkId
	 *
	 */
	public String bindingUserMLInfo(){
		if(sn>0){
			getUserInfoService().bindingUserMLInfo(pkId,sn);
			mapResult.put("success", true);
		}else{
			mapResult.put("success", false);
			mapResult.put("errorMessage", "要绑定的密码卡无效！("+sn+")");
		}
		return "json";
	}
	
	/**
	 * 
	 *  @Description:解除绑定用户密令卡
	 *  @MethodName :jcBinding
	 *  @Author     : LZYYJ
	 *  @CreateDate :2013-11-15 下午05:18:12 
	 *  @param pkId
	 *
	 */
	public String jcBinding() {
		try {
			getUserInfoService().jcBinding(pkId);
			mapResult.put("success", true);
		} catch (Exception e) {
			e.printStackTrace();
			mapResult.put("success", false);
			mapResult.put("errorMessage", ""+e.getMessage());
		}
		return "json";
	}
	
	/**
	 * 
	 *  @描述:瑞宏升统一用户管理模块获取代办事宜消息数
	 *  @方法名称 :rhsMessage
	 *  @作者     :yaosq
	 *  @创建日期 :2014-4-21 下午02:41:59 
	 *  @param userName
	 */
	public void rhsMessage(){
		//通过userName获取该用户的代办事宜数
		this.writeResponse("0");
		return;
	}
}
